/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.fi.muni.diplomka.common;

/**
 * Class representing single Squad in Army
 *
 * @author Jakub Kutil
 */
public class Squad {

    private int position;
    private Unit unit;
    private float count;
    private float lostCount = 0;
    private float threshold;
    private boolean active = true;

    public Squad() {
    }

    public int getPosition() {
        return position;
    }

    public void setPosition(int position) {
        this.position = position;
    }

    public Unit getUnit() {
        return unit;
    }

    public void setUnit(Unit unit) {
        this.unit = unit;
    }

    public float getCount() {
        return count;
    }

    public void setCount(float count) {
        this.count = count;
    }

    public float getLostCount() {
        return lostCount;
    }

    public void setLostCount(float lostCount) {
        this.lostCount = lostCount;
    }

    public float getThreshold() {
        return threshold;
    }

    public void setThreshold(float threshold) {
        this.threshold = threshold;
    }

    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    /**
     * Kills Unit
     */
    public void lowerCount() {
        count--;
    }

    /**
     * Adds kill to death toll
     */
    public void raiseLostCount() {
        lostCount++;
    }

    /**
     * Decides if squad is unable to fight
     *
     * @return true if squad can not fight anymore
     */
    public boolean isSquadBroken() {

        if ((lostCount / (count + lostCount)) * 100 >= threshold) {
            return true;
        }
        return false;
    }    
}
